﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Interface
{
    public partial class Form1 : Form
    {
        MainClass data;
        int yearIndex;
        
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
       
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int index = getComboBoxIndex();
            string yearString = this.data.getListOfYears()[index];
            this.dataGridView1.DataSource = this.data.Query1(yearString);
            dataGridView1.Columns[0].Width = 100;
            dataGridView1.Columns[1].Width = 105;
            dataGridView1.ReadOnly = true;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            this.dataGridView3.DataSource = this.data.Query3();
            dataGridView3.Columns[0].Width = 450;
            dataGridView3.Columns[1].Width = 350;
            dataGridView3.Columns[2].Width = 60;

            dataGridView3.ReadOnly = true;
        }

        private void sairToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private int getComboBoxIndex()
        {
            return this.yearIndex = this.comboBox1.SelectedIndex;
        }


        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            this.data = new MainClass();
            this.data.database();
            this.comboBox1.Items.AddRange(this.data.getListOfYears().ToArray());
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.dataGridView2.DataSource = this.data.Query2();
            dataGridView2.Columns[0].Width = 100;
            dataGridView2.Columns[1].Width = 350;
            dataGridView2.Columns[2].Width = 100;
            dataGridView2.ReadOnly = true;
        }

        private void tabPage2_Click(object sender, EventArgs e)
        {

        }
    }
}
